<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get a text attribute</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="numberformatter.getsymbol.html">NumberFormatter::getSymbol</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="numberformatter.parsecurrency.html">NumberFormatter::parseCurrency</a></div>
 <div class="up"><a href="class.numberformatter.html">NumberFormatter</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="numberformatter.gettextattribute" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">NumberFormatter::getTextAttribute</h1>
  <h1 class="refname">numfmt_get_text_attribute</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PECL intl &gt;= 1.0.0)</p><p class="refpurpose"><span class="refname">NumberFormatter::getTextAttribute</span> -- <span class="refname">numfmt_get_text_attribute</span> &mdash; <span class="dc-title">Get a text attribute</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-numberformatter.gettextattribute-description">
  <h3 class="title">说明</h3>
  <p class="para">
   面向对象风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span>
   <span class="type">string</span> 
   <span class="methodname"><strong>NumberFormatter::getTextAttribute</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$attr</code></span>
   )</div>

  <p class="para rdfs-comment">
   过程化风格
  </p>
  <div class="methodsynopsis dc-description">
   <span class="type">string</span> 
   <span class="methodname"><strong>numfmt_get_text_attribute</strong></span>
    ( <span class="methodparam"><span class="type"><a href="class.numberformatter.html" class="type NumberFormatter">NumberFormatter</a></span> <code class="parameter">$fmt</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$attr</code></span>
   )</div>

  <p class="para rdfs-comment">
   Get a text attribute associated with the formatter. An example of a text
   attribute is the suffix for positive numbers. If the formatter does not
   understand the attribute,
   <strong><code>U_UNSUPPORTED_ERROR</code></strong>
   error is produced. Rule-based formatters only understand
   <strong><code>NumberFormatter::DEFAULT_RULESET</code></strong> and
   <strong><code>NumberFormatter::PUBLIC_RULESETS</code></strong>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-numberformatter.gettextattribute-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">fmt</code></em></dt>

     <dd>

      <p class="para">
       <a href="class.numberformatter.html" class="classname">NumberFormatter</a> object.
      </p>
     </dd>

    
    
     <dt>
<em><code class="parameter">attr</code></em></dt>

     <dd>

      <p class="para">
       Attribute specifier - one of the
       <a href="class.numberformatter.html#intl.numberformatter-constants.unumberformattextattribute" class="link">
        text attribute</a> constants.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>



 <div class="refsect1 returnvalues" id="refsect1-numberformatter.gettextattribute-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Return attribute value on success, or <strong><code>FALSE</code></strong> on error.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-numberformatter.gettextattribute-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-2454">
   <p><strong>Example #1 <span class="function"><strong>numfmt_get_text_attribute()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$fmt&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">numfmt_create</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'de_DE'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NumberFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">DECIMAL&nbsp;</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"Prefix:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">numfmt_get_text_attribute</span><span style="color: #007700">(</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NumberFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">NEGATIVE_PREFIX</span><span style="color: #007700">).</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">numfmt_format</span><span style="color: #007700">(</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">1234567.891234567890000</span><span style="color: #007700">).</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">numfmt_set_text_attribute</span><span style="color: #007700">(</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NumberFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">NEGATIVE_PREFIX</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"MINUS"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"Prefix:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">numfmt_get_text_attribute</span><span style="color: #007700">(</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NumberFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">NEGATIVE_PREFIX</span><span style="color: #007700">).</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">numfmt_format</span><span style="color: #007700">(</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">,&nbsp;-</span><span style="color: #0000BB">1234567.891234567890000</span><span style="color: #007700">).</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <div class="example" id="example-2455">
   <p><strong>Example #2 OO example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$fmt&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">NumberFormatter</span><span style="color: #007700">(&nbsp;</span><span style="color: #DD0000">'de_DE'</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">NumberFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">DECIMAL&nbsp;</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"Prefix:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getTextAttribute</span><span style="color: #007700">(</span><span style="color: #0000BB">NumberFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">NEGATIVE_PREFIX</span><span style="color: #007700">).</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(-</span><span style="color: #0000BB">1234567.891234567890000</span><span style="color: #007700">).</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">setTextAttribute</span><span style="color: #007700">(</span><span style="color: #0000BB">NumberFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">NEGATIVE_PREFIX</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"MINUS"</span><span style="color: #007700">);<br />echo&nbsp;</span><span style="color: #DD0000">"Prefix:&nbsp;"</span><span style="color: #007700">.</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getTextAttribute</span><span style="color: #007700">(</span><span style="color: #0000BB">NumberFormatter</span><span style="color: #007700">::</span><span style="color: #0000BB">NEGATIVE_PREFIX</span><span style="color: #007700">).</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo&nbsp;</span><span style="color: #0000BB">$fmt</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">format</span><span style="color: #007700">(-</span><span style="color: #0000BB">1234567.891234567890000</span><span style="color: #007700">).</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

  </div>
  <p class="para">以上例程会输出：</p>
  <div class="example-contents screen">
<div class="cdata"><pre>
Prefix: -
-1.234.567,891
Prefix: MINUS
MINUS1.234.567,891
</pre></div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-numberformatter.gettextattribute-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="numberformatter.geterrorcode.html" class="function" rel="rdfs-seeAlso">numfmt_get_error_code()</a> - Get formatter's last error code.</span></li>
    <li class="member"><span class="function"><a href="numberformatter.getattribute.html" class="function" rel="rdfs-seeAlso">numfmt_get_attribute()</a> - Get an attribute</span></li>
    <li class="member"><span class="function"><a href="numberformatter.settextattribute.html" class="function" rel="rdfs-seeAlso">numfmt_set_text_attribute()</a> - Set a text attribute</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="numberformatter.getsymbol.html">NumberFormatter::getSymbol</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="numberformatter.parsecurrency.html">NumberFormatter::parseCurrency</a></div>
 <div class="up"><a href="class.numberformatter.html">NumberFormatter</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
